package main

import "fmt"

func main() {
	nums := []int{7, 5, 3, 9, 1, 6, 8, 4, 0, 2}
	fmt.Printf("%v", sort(nums))
}

func sort(nums []int) []int {
	if len(nums) == 0 || len(nums) == 1 {
		return nums
	}

	sourceNum := nums[0]
	sourceList := sort(nums[1:])

	var list []int
	if sourceNum >= sourceList[len(sourceList)-1] {
		list = append(sourceList, sourceNum)
	} else {
		for i := 0; i < len(sourceList); i++ {
			if sourceNum < sourceList[i] {
				//注意：切片append
				list = append(list, sourceList[:i]...)
				list = append(list, sourceNum)
				list = append(list, sourceList[i:]...)
				break
			}
		}
	}
	return list

}
